import React, { Component } from 'react'
import style from "./evaluation.module.css"
import {LeftOutlined } from '@ant-design/icons'
import {connect} from "react-redux"
import { withRouter } from "react-router-dom"
import axios from "axios"

const data=({})

class pinglun extends Component  {
    state = {
        con:"",
        files: data,
        multiple: false,
      }
      onChange = (files, type, index) => {
        console.log(files, type, index);
        this.setState({
          files,
        });
      }
      changeCon=(e)=>{
        this.setState({
            con:e.target.value
        })
        console.log(this.state.con,"con")
      }


      submit=()=>{
        console.log(this.state,"lalala")
        const headerJSON = {
            "Content-Type": "application/json;charset=UTF-8"
        };
        axios({
            url:"/pinglun/comment/insertComment",
            method:"post",
            header:headerJSON,
            data:{
                bid:this.props.location.state.id,
                phone:JSON.stringify(12345678901),
                // img:this.state.files,
                content:this.state.con,
                // time:time,
            }
        }).then(res=>{
            // this.setState({
            //     house:res.data.build,
            // })
            console.log(res)
        })
      }
    render() {
        const { files } = this.state;
        console.log(this.props.location.state.id,"id")
        return (
            <div className={style.pinglun}>
                <div className={style.pinglunTil}>
                   <span onClick={()=>{
                        this.props.history.go(-1)}}><LeftOutlined /></span>
                   <h4 className={style.pinglunTilCon}>楼盘评论</h4>
                </div>

                <div className={style.pinglunBox}>
                    <div className={style.pinglunBoxTil}><b>楼盘评论</b></div>
                    <div className={style.huanjing}>
                        居住环境
                    </div>
                    <div className={style.pinglunBoxCon}>

                        <textarea className={style.pinglunText}
                        value={this.state.con}
                        onChange={this.changeCon}
                        placeholder="说点什么"
                        ></textarea>

                        <div className={style.pinglunSubmit} onClick={this.submit}>提交评论</div>
                    </div>
                </div>

            </div>
        )
    }
}

export default connect(
        state=>({
            user:state.user,
            token:state.token
        })
    )(withRouter(pinglun))